import multiprocessing
import os
import sys
from spider.util.multi_thread_window import MainWindow
from scrapy.utils.project import get_project_settings
import subprocess
import time
from configparser import ConfigParser
from multiprocessing import Process, Queue

import pymysql
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtCore import pyqtSignal, QThreadPool, QObject, QRunnable, QThread
from PyQt5.QtWidgets import QFileDialog, QDialog, QMainWindow
from scrapy.crawler import CrawlerRunner, CrawlerProcess

from scrapy.utils.project import get_project_settings
from twisted.internet import reactor

from spider.util.mysignal import MySignal
from spider.util.ui_dialog import Ui_Dialog
from spider.util.ui_main import Ui_MainWindow

import scrapy.settings

import scrapy.spiderloader
import scrapy.statscollectors
import scrapy.logformatter
import scrapy.dupefilters
import scrapy.squeues

import scrapy.extensions.spiderstate
import scrapy.extensions.corestats
import scrapy.extensions.telnet
import scrapy.extensions.logstats
import scrapy.extensions.memusage
import scrapy.extensions.memdebug
import scrapy.extensions.feedexport
import scrapy.extensions.closespider
import scrapy.extensions.debug
import scrapy.extensions.httpcache
import scrapy.extensions.statsmailer
import scrapy.extensions.throttle

import scrapy.core.scheduler
import scrapy.core.engine
import scrapy.core.scraper
import scrapy.core.spidermw
import scrapy.core.downloader

import scrapy.downloadermiddlewares.stats
import scrapy.downloadermiddlewares.httpcache
import scrapy.downloadermiddlewares.cookies
import scrapy.downloadermiddlewares.useragent
import scrapy.downloadermiddlewares.httpproxy
import scrapy.downloadermiddlewares.ajaxcrawl
import scrapy.downloadermiddlewares.decompression
import scrapy.downloadermiddlewares.defaultheaders
import scrapy.downloadermiddlewares.downloadtimeout
import scrapy.downloadermiddlewares.httpauth
import scrapy.downloadermiddlewares.httpcompression
import scrapy.downloadermiddlewares.redirect
import scrapy.downloadermiddlewares.retry
import scrapy.downloadermiddlewares.robotstxt

import scrapy.spidermiddlewares.depth
import scrapy.spidermiddlewares.httperror
import scrapy.spidermiddlewares.offsite
import scrapy.spidermiddlewares.referer
import scrapy.spidermiddlewares.urllength

import scrapy.pipelines
import pywin
import pythonwin, pywin32_system32
import win32com
import win32api

import scrapy.core.downloader.handlers.http
import scrapy.core.downloader.contextfactory


if __name__ == "__main__":
    multiprocessing.freeze_support()  # 打包多进程需要加这一行
    app = QtWidgets.QApplication(sys.argv)
    mainWindow = MainWindow()
    mainWindow.show()
    sys.exit(app.exec_())
